<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>设备借出审核</title>
    <#include "../../common/link.ftl">
    <link rel="stylesheet" type="text/css" href="/js/plugins/bootstrap-select/bootstrap-select.css"/>
    <script src="/js/plugins/bootstrap-select/bootstrap-select.js"></script>
    <link type="text/css" rel="stylesheet" href="/js/plugins/uploadifive/uploadifive.css" />
    <script type="text/javascript" src="/js/plugins/uploadifive/jquery.uploadifive.min.js"></script>
    <script src="/js/ckeditor/ckeditor.js"></script>

    <script>
        $(function () {
            jeDate({
                dateCell:"#lendingTime",
                isinitVal:false,  //是否初始化时间
                isTime:true, //是否开启时间选择
                minDate:"2014-09-19 00:00:00"
            })
            jeDate({
                dateCell:"#returnTime",
                isinitVal:false,  //是否初始化时间
                isTime:true, //是否开启时间选择
                minDate:"2014-09-19 00:00:00"
            })

            // 归还失败理由
            /*var returnDiv;
            if($("#isReturn").val() == 2){
                $("#return").after(returnDiv);
            }else {
                returnDiv = $("#returnRe").detach();
            }

            // 借出失败理由
            var agreeDiv;
            if($("#isAgree").val() == 2){
                $("#agree").after(returnDiv);
            }else {
                returnDiv = $("#agreeRe").detach();
            }*/

            // 保存
            $("#submitBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if(data.code == 200){ //用alert或者popup都可以
                        $.messager.alert("温馨提示","保存成功!2s后自动关闭")
                        window.setTimeout(function () {
                            window.location.href = "/deviceRecord/admin/list.do";
                        },2000)
                    }else{
                        $.messager.popup(data.msg)
                    }
                });
            })

            // 取消
            $(".cancleBtn").click(function () {
                //document.referrer 上一个请求路径
                var url = document.referrer ? document.referrer : "/";
                window.location.href = url;
            });
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="LendReturnAdmin"/>
    <#include "../../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>设备借用记录</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="/deviceRecord/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="${(deviceRecord.id)!}"  name="id" >
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="deviceName" class="col-sm-2 control-label">设备名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="deviceName" name="deviceName"  value="${(deviceRecord.number)!}" placeholder="请输入设备名称">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="deviceNumber" class="col-sm-2 control-label">借用数量：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number"  value="${(deviceRecord.number)!}" placeholder="请输入借用数量">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="association" class="col-sm-2 control-label">社团名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="association" name="association"  value="${(deviceRecord.association)!}" placeholder="请输入社团名称">
                        </div>
                    </div>

                    <div class="form-group" id="agree">
                        <label for="isAgree" class="col-sm-2 control-label">是否同意借用：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="isAgree" name="isAgree">
                                <option value="-1">全部</option>
                                <option value="0">申请中</option>
                                <option value="1">借出成功</option>
                                <option value="2">借出失败</option>
                            </select>
                            <script>
                                $("#isAgree").val(${(deviceRecord.isAgree)!'-1'})
                            </script>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="lendingTime" class="col-sm-2 control-label">借出时间：</label>
                        <div class="col-sm-6 input-daterange" id="jeDate">
                            <input type="text" class="input-sm form-control wicon" name="lendingTime" id="lendingTime"
                                   value="${(deviceRecord.lendingTime?string('yyyy-MM-dd HH:mm:ss'))!}" />
                        </div>
                    </div>

                    <div class="form-group" id="agreeRe">
                        <label for="agreeRefuse" class="col-sm-2 control-label">借出失败理由：</label>
                        <div class="col-sm-6">
                            <textarea class="form-control" name="agreeRefuse" id="agreeRefuse">${(deviceRecord.agreeRefuse)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group" id="return">
                        <label for="isReturn" class="col-sm-2 control-label">是否已经归还：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="isReturn" name="isReturn">
                                <option value="-1">全部</option>
                                <option value="0">申请中</option>
                                <option value="1">归还成功</option>
                                <option value="2">归还失败</option>
                            </select>
                            <script>
                                $("#isReturn").val("${(deviceRecord.isReturn)!'-1'}")
                            </script>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="returnTime" class="col-sm-2 control-label">归还时间：</label>
                        <div class="col-sm-6 input-daterange" id="jeDate">
                            <input type="text" class="input-sm form-control wicon" name="returnTime" id="returnTime"
                                   value="${(deviceRecord.returnTime?string('yyyy-MM-dd HH:mm:ss'))!}" />
                        </div>
                    </div>

                    <div class="form-group" id="returnRe">
                        <label for="returnRefuse" class="col-sm-2 control-label">归还失败理由：</label>
                        <div class="col-sm-6">
                            <textarea class="form-control" name="returnRefuse" id="returnRefuse">${(deviceRecord.returnRefuse)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="site" class="col-sm-2 control-label">负责人：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="dutyName" name="dutyName" value="${(deviceRecord.dutyName)!}" placeholder="请输入负责人姓名">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="site" class="col-sm-2 control-label">联系方式：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="mobile" name="mobile" value="${(deviceRecord.mobile)!}" placeholder="请输入负责人电话">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="reason" class="col-sm-2 control-label">申请理由：</label>
                        <div class="col-sm-6">
                            <textarea  class="form-control" name="reason" >${(deviceRecord.reason)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6" style="margin-left: 35%">
                            <!--button如果是在form表单内部,不写type默认就是submit-->
                            <!-- 验证插件只支持submit按钮提交-->
                            <button id="submitBtn" type="button" class="btn btn-primary" style="margin-right: 20px; margin-bottom: 10px">保存</button>
                            <button type="button" class="btn btn-default cancleBtn" data-dismiss="modal" style="margin-left: 20px; margin-bottom: 10px">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
    <#include "../../common/footer.ftl">
</div>
</body>
</html>
